package net.kelissa.jenetic.impl.mutator;

import java.util.List;

import net.kelissa.jenetic.Gene;
import net.kelissa.jenetic.Mutator;
import net.kelissa.jenetic.RandomUtil;

public class Permutator implements Mutator
{

  private int maxPermutationCount;

  public Permutator()
  {
    this.maxPermutationCount = 5;
  }

  public Permutator(int maxPermutationCount)
  {
    this.maxPermutationCount = maxPermutationCount;
  }

  @Override
  public void mutate(List<Gene> genes)
  {
    if (genes.size() > 1)
    {
      int rand = RandomUtil.getRandom(1, this.maxPermutationCount + 1);
      for (int i = 0; i < rand; i++)
      {
        RandomUtil.permutation(genes);
      }
    }
  }

  // --------------------------------------
  public int getMaxPermutationCount()
  {
    return maxPermutationCount;
  }

  public void setMaxPermutationCount(int maxPermutationCount)
  {
    this.maxPermutationCount = maxPermutationCount;
  }



}
